<script>
function pad(number, length) {
	   
    var str = '' + number;
    while (str.length < length) {
        str = '0' + str;
    }
    return str;
}
 </script>

<script language="javascript">
//<!-- Load the ActiveX object  -->
var x = new ActiveXObject("ANamespace.AClass");
var b = new ActiveXObject("ANamespace.AClass");
  
 function LeerTarjetaAuto()
 {
    var strATR = x.identificarTarjeta();
  //  bLectoraConectada= x.conectar();
/*if((bLectoraConectada==false)&&((strATR.charAt(0))=="E"))
	{
	 // FD 18-1-12   alert('No se ha ingresado ninguna tarjeta');
      //window.open('http://localhost/hs/DatosPacienteActual/HCPaciente/HCPacienteLectora/HCPacienteLectora.php','mywindow' ,'width=800,height=600,directories=yes,resizable=yes,copyhistory=yes,scrollbars=yes,status=yes,menubar=yes');   
    //titlebar
       // FD 18-1-12  window.open('DatosPacienteActual/HCPaciente/HCPacienteLectora/HCPacienteLectora.php?Pac='+Pac,'mywindow' ,'width=800,height=700,directories=yes,resizable=yes,copyhistory=yes,scrollbars=yes,status=yes,menubar=yes');   
        
	}
else 
{}
*/
if ((bLectoraConectada==false)&&((strATR.charAt(0))!="E"))
	{  
	   NumReaded=strATR.charAt(37)
       //alert('PASE');
       //alert('Card:'+NumReaded);
	   if(NumReaded==9)
       {
       //  window.location.href = "http://localhost/hs/Login.php?Med="+NumReaded;
       }
       else{
    	   bLectoraConectada=true;       
           Pac=strATR.charAt(37);    
                    
    	  // alert ('hay tarjeta');
              // if(selr) window.location.href = "http://healthsolution.com.ar/MainHCD.php?Pac=" +strATR;
         window.location.href = "http://localhost/hs/MainHCD.php?Pac=" +Pac;
         window.open('DatosPacienteActual/HCPaciente/HCPacienteLectora/HCPacienteLectora.php?Pac='+Pac,'mywindow' ,'width=800,height=700,directories=yes,resizable=yes,copyhistory=yes,scrollbars=yes,status=yes,menubar=yes');   
       }
   }
}

function EscribirDatosMain(string strDatos)
{   var strDatosE="HOLA";
  
    var boEscribi=x.escribirenTarjeta(strDatosE)
    
}

 </script>

 <script>
function fnc() {
    var d_names = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");

    var m_names = new Array("Enero", "Febrero", "Marzo",
"Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
"Octubre", "Noviembre", "Diciembre");

    var reloj = new Date();


    var str = "";
    str = reloj.getDate() + " de " + m_names[reloj.getMonth()] + " de " + (reloj.getYear() + 1900).toString() + " " + pad(reloj.getHours(),2) + ":" + pad(reloj.getMinutes(),2) + ":" + pad(reloj.getSeconds(),2);
    document.getElementById("reloj").innerHTML = str;

    window.setTimeout("fnc()", 2000);

    LeerTarjetaAuto();    
}

$(function() {
        $( "#MenuAcciones" ).fadeTo("100",0.5);
        $( "#divDatosMedico" ).fadeTo("100",0.5);
        $( "#divDatosPaciente" ).fadeTo("100",0.5);
        $( "#divBotonPrinAccion1" ).fadeTo("100",0.7);
        $( "#divBotonPrinAccion2" ).fadeTo("100",0.7);
        $( "#divBotonPrinAccion3" ).fadeTo("100",0.7);
        $( "#divBotonPrinAccion4" ).fadeTo("100",0.7);
        
            
        $( "#divDatosMedico" ).hide();
        $( "#divDatosPaciente" ).hide();        
        
        //ModPrincipal
        // ** ModPaciente   
	});
		
/////CHANGE COLOR BOTONES FUNCTION//////////
function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
</script>